package org.obs.core.hibernate.operations;

import java.util.UUID;

import org.hibernate.Session;
import org.obs.core.HibernateOperation;
import org.obs.domain.UserRequest;

public class CreateUserRequestOperation implements HibernateOperation <Object>{

	private String email;

	private String password;
	
	private String nick;
	
	public CreateUserRequestOperation(String n, String e, String p) {
		this.nick = n;
		this.email = e;
		this.password = p;
	}

	public UserRequest execute(Session session) {
		UserRequest user = new UserRequest();
		user.setEmail(email);
		user.setPassword(password);
		user.setNick(nick);
		String n = UUID.randomUUID().toString();
		String v = UUID.randomUUID().toString();
		user.setN(n);
		user.setV(v);
		session.save(user);
		return user;
	}

}
